package com.qf.service.impl;


//import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qf.dao.CheckItemMapper;
import com.qf.entity.CheckItem;
import com.qf.entity.PageResult;
import com.qf.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 检查项管理
 * 服务实现类
 */
@Service//服务注解
//@Transactional//事务注解
public class CheckItemServiceImpl implements CheckItemService {

    //注入dao
    @Autowired
    private CheckItemMapper checkItemMapper;

    /**
     * 查询所有检查项
     * @return
     */
    public List<CheckItem> findAll() {
        return checkItemMapper.findAll();
    }
    /**
     * 新增检查项
     * @param checkItem
     */
    @Override
    public void add(CheckItem checkItem) {
        checkItemMapper.add(checkItem);
    }

    /**
     * 删除检查项
     * @param id
     */
    @Override
    public void delete(Integer id) {
        checkItemMapper.deleteById(id);
    }

    /**
     * 编辑检查项
     * @param checkItem
     */
    @Override
    public void edit(CheckItem checkItem) {
        checkItemMapper.edit(checkItem);
    }

    /**
     * 通过id查询检查项
     * @param id
     * @return
     */
    public CheckItem findById(Integer id) {
        return checkItemMapper.findById(id);
    }

    /**
     * 分页查询
     * @param currentPage
     * @param pageSize
     * @param queryString
     * @return
     */
    @Override
    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<CheckItem> page = checkItemMapper.selectByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }
}
